package org.example.petsystem.controller;

import org.example.petsystem.entity.ResultBody;
import org.example.petsystem.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 消息控制器
 */
@RestController
@RequestMapping("/Message")
@CrossOrigin(origins = "*")
public class MessageController {

    @Autowired
    private MessageService messageService;
    /**
     * 获取消息列表
     * @param map 包含参数的Map
     * @return 消息列表
     */
    @PostMapping("/getMessageList")
    public ResultBody getMessageList(@RequestBody Map<String, Object> map) {
        return messageService.getMessageList(map);
    }
    /**
     * 标记消息已读
     * @param map 包含参数的Map
     * @return 操作结果
     */
    @PostMapping("/markAsRead")
    public ResultBody markAsRead(@RequestBody Map<String, Object> map) {
        return messageService.markAsRead(map);
    }
    /**
     * 批量标记已读
     * @param map 包含参数的Map
     * @return 操作结果
     */
    @PostMapping("/batchMarkAsRead")
    public ResultBody batchMarkAsRead(@RequestBody Map<String, Object> map) {
        return messageService.batchMarkAsRead(map);
    }

    /**
     * 删除消息
     * @param map 包含参数的Map
     * @return 操作结果
     */
    @PostMapping("/deleteMessage")
    public ResultBody deleteMessage(@RequestBody Map<String, Object> map) {
        return messageService.deleteMessage(map);
    }

    /**
     * 发送消息
     * @param map 包含参数的Map
     * @return 操作结果
     */
    @PostMapping("/sendMessage")
    public ResultBody sendMessage(@RequestBody Map<String, Object> map) {
        return messageService.sendMessage(map);
    }
    /**
     * 获取聊天记录
     * @param map 包含参数的Map
     * @return 聊天记录列表
     */
    @PostMapping("/getChatMessages")
    public ResultBody getChatMessages(@RequestBody Map<String, Object> map) {
        return messageService.getChatMessages(map);
    }
} 